Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zetaclient): add TSS sign latency histogram #2567

Merged
merged 2 commits into from
Jul 26, 2024

Conversation

gartnera
Copy link
Member

@gartnera gartnera commented Jul 26, 2024

Add a zetaclient_sign_latency histogram metric to allow easily debugging how many keysigns are active. Output:

root@zetaclient0:/usr/local/bin# curl -s zetaclient0:8886 | grep sign_latency
# HELP zetaclient_sign_latency Histogram of the TSS keysign latency
# TYPE zetaclient_sign_latency histogram
zetaclient_sign_latency_bucket{result="error",le="1"} 0
zetaclient_sign_latency_bucket{result="error",le="15"} 0
zetaclient_sign_latency_bucket{result="error",le="30"} 0
zetaclient_sign_latency_bucket{result="error",le="60"} 2639
zetaclient_sign_latency_bucket{result="error",le="120"} 2639
zetaclient_sign_latency_bucket{result="error",le="240"} 2639
zetaclient_sign_latency_bucket{result="error",le="+Inf"} 2639
zetaclient_sign_latency_sum{result="error"} 81938.54814908499
zetaclient_sign_latency_count{result="error"} 2639
zetaclient_sign_latency_bucket{result="success",le="1"} 458
zetaclient_sign_latency_bucket{result="success",le="15"} 882
zetaclient_sign_latency_bucket{result="success",le="30"} 894
zetaclient_sign_latency_bucket{result="success",le="60"} 963
zetaclient_sign_latency_bucket{result="success",le="120"} 963
zetaclient_sign_latency_bucket{result="success",le="240"} 963
zetaclient_sign_latency_bucket{result="success",le="+Inf"} 963
zetaclient_sign_latency_sum{result="success"} 3795.4701828549973
zetaclient_sign_latency_count{result="success"} 963
Screenshot 2024-07-25 at 8 35 15 PM

Closes #2564

Summary by CodeRabbit

  • New Features

    • Introduced a new metric for tracking latency in TSS keysigning operations, enhancing performance monitoring.
    • Improved the message signing process tracking by returning a closure function that allows for better error handling and metrics updates.
  • Bug Fixes

    • Enhanced error handling in the message signing process to ensure accurate status tracking.
  • Tests

    • Updated tests to better validate the lifecycle events of message signing, ensuring correct handling of active signing counts.

Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Walkthrough

The recent changes enhance the observability and control flow of the signing process within the system. Key modifications include the introduction of a new histogram metric for tracking TSS keysign latency, adjustments to the message signing methods to incorporate closures for better lifecycle management, and updates to corresponding test cases for improved validation. These changes collectively aim to bolster performance monitoring and error handling, ensuring a more robust and maintainable codebase.

Changes

File Path Change Summary
contrib/localnet/docker-compose-monitoring.yml Removed ports mapping for Prometheus, restricting external access for security or architectural improvements.
zetaclient/metrics/metrics.go Introduced SignLatency, a new histogram vector for tracking TSS keysign operation latency, enhancing performance visibility.
zetaclient/tss/concurrent_keysigns_tracker.go Updated StartMsgSign to return a closure for handling the end of signing operations, integrating the previous EndMsgSign logic.
zetaclient/tss/concurrent_keysigns_tracker_test.go Modified tests to utilize the closure from StartMsgSign, improving the validation of message signing lifecycle events.
zetaclient/tss/tss_signer.go Adjusted Sign and SignBatch methods to capture and invoke StartMsgSign closure, enhancing error handling during signing.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ConcurrentKeysignsTracker
    participant Metrics

    Client->>ConcurrentKeysignsTracker: StartMsgSign()
    ConcurrentKeysignsTracker->>Metrics: Register start time
    ConcurrentKeysignsTracker-->>Client: Closure (end function)

    Client->>ConcurrentKeysignsTracker: Complete signing (with result)
    ConcurrentKeysignsTracker->>Metrics: Log end time and success/failure
Loading

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jul 26, 2024

Codecov Report

Attention: Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.

Project coverage is 46.64%. Comparing base (545896d) to head (1f4e963).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2567      +/-   ##
===========================================
+ Coverage    46.63%   46.64%   +0.01%     
===========================================
  Files          464      464              
  Lines        30843    30850       +7     
===========================================
+ Hits         14383    14390       +7     
  Misses       15604    15604              
  Partials       856      856              
Files Coverage Δ
zetaclient/metrics/metrics.go 75.00% <ø> (ø)
zetaclient/tss/concurrent_keysigns_tracker.go 100.00% <100.00%> (ø)
zetaclient/tss/tss_signer.go 9.56% <0.00%> (ø)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5cd5f5a and ec33f27.

Files selected for processing (5)
  • contrib/localnet/docker-compose-monitoring.yml (1 hunks)
  • zetaclient/metrics/metrics.go (1 hunks)
  • zetaclient/tss/concurrent_keysigns_tracker.go (2 hunks)
  • zetaclient/tss/concurrent_keysigns_tracker_test.go (1 hunks)
  • zetaclient/tss/tss_signer.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • contrib/localnet/docker-compose-monitoring.yml
Additional context used
Path-based instructions (4)
zetaclient/tss/concurrent_keysigns_tracker_test.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/tss/concurrent_keysigns_tracker.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/metrics/metrics.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

zetaclient/tss/tss_signer.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

GitHub Check: codecov/patch
zetaclient/tss/tss_signer.go

[warning] 249-249: zetaclient/tss/tss_signer.go#L249
Added line #L249 was not covered by tests


[warning] 251-251: zetaclient/tss/tss_signer.go#L251
Added line #L251 was not covered by tests


[warning] 331-331: zetaclient/tss/tss_signer.go#L331
Added line #L331 was not covered by tests


[warning] 333-333: zetaclient/tss/tss_signer.go#L333
Added line #L333 was not covered by tests

Additional comments not posted (4)
zetaclient/tss/concurrent_keysigns_tracker_test.go (1)

21-24: Ensure comprehensive test coverage.

The test correctly captures and invokes the return values from StartMsgSign. However, consider adding more assertions to verify the state before and after each invocation to ensure comprehensive test coverage.

zetaclient/tss/concurrent_keysigns_tracker.go (1)

30-54: Ensure thread safety and metric accuracy.

The closure correctly handles the end of the signing process and updates the metrics. Ensure that the mutex is properly used to maintain thread safety. The use of prometheus.Labels{"result": result} is appropriate for categorizing the results.

zetaclient/metrics/metrics.go (1)

108-114: Ensure appropriate bucket ranges for latency.

The SignLatency histogram vector is correctly defined. Ensure that the bucket ranges (1, 15, 30, 60, 120, 240 seconds) are appropriate for the expected latency distribution of TSS keysign operations.

zetaclient/tss/tss_signer.go (1)

249-251: Ensure thorough testing of new tracking logic.

The changes to track the signing process using StartMsgSign and EndMsgSign improve the control flow. However, these lines are not covered by tests.

Would you like me to generate the unit tests for these changes or open a GitHub issue to track this task?

Tools
GitHub Check: codecov/patch

[warning] 249-249: zetaclient/tss/tss_signer.go#L249
Added line #L249 was not covered by tests


[warning] 251-251: zetaclient/tss/tss_signer.go#L251
Added line #L251 was not covered by tests

zetaclient/tss/tss_signer.go Show resolved Hide resolved
Copy link
Contributor

@swift1337 swift1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Left some minor non-blocking comments

zetaclient/metrics/metrics.go Outdated Show resolved Hide resolved
zetaclient/tss/concurrent_keysigns_tracker.go Show resolved Hide resolved
@gartnera gartnera force-pushed the zetaclient-keysign-histogram branch from ec33f27 to 1f4e963 Compare July 26, 2024 16:54
@gartnera gartnera enabled auto-merge July 26, 2024 16:54
@gartnera gartnera added this pull request to the merge queue Jul 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 26, 2024
@gartnera gartnera added this pull request to the merge queue Jul 26, 2024
Merged via the queue into develop with commit be48f07 Jul 26, 2024
28 checks passed
@gartnera gartnera deleted the zetaclient-keysign-histogram branch July 26, 2024 19:12
@gartnera gartnera added the zetaclient Issues related to ZetaClient label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
zetaclient Issues related to ZetaClient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use a histogram for zetaclient keysigning
3 participants